import Vue from "vue";
import Router from "vue-router";

const slaveLogin = (r) =>
  require.ensure([], () => r(require("@/views/Login.vue")));

import NProgress from "nprogress";

Vue.use(Router);
let constRouters = [
  {
    path: "/",
    hidden: true,
    redirect: {
      name: "slaveLogin",
    },
  },
  {
    path: "/login",
    name: "slaveLogin",
    component: slaveLogin,
    hidden: true,
    meta: {
      title: "从节点登录",
      requireAuth: false,
    },
  },
//   {
//     path: "/slave",
//     component: slaveHome,
//     leaf: true, //只有一个节点
//     hidden: true,
//     icon: "iconyingyongfuzhi6",
//     meta: {
//       title: "企业信息",
//     },
//     children: [
//       {
//         path: "/slave/companyInfo",
//         name: "companyInfo",
//         component: companyInfo,
//         meta: {
//           title: "编辑企业信息",
//         },
//       },
//     ],
//   },
 
];


//合并两个路由
// let routes = new Set([...masterRoutes, ...slaveRoutes]) as any;

const router = new Router({
  routes: constRouters,
  mode: "history",
});


// 免登陆路径
const WHITELIST = ["/login"];
var authlist = [];
let firstTime = true;
router.beforeEach((to, from, next) => {
  //路由钩子改标题
  // if (to.meta.title) {
  //   document.title = to.meta.title;
  // }
  NProgress.start();
  next();
});

router.afterEach((to, from) => {
  NProgress.done();
});

export default router;
